package com.wicket.okrcomponent.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wicket.okrcomponent.common.dto.FieldInfo;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wicket.okrcomponent.base.service.MCustomFields3Service;
import com.wicket.okrcomponent.common.exception.BizException;
import com.wicket.okrcomponent.common.tools.StringUtils;
import com.wicket.okrcomponent.common.util.CommonFunctionHelper;
import com.wicket.okrcomponent.dal.mapper.mbg.CustomFields3Mapper;
import com.wicket.okrcomponent.dal.po.mbg.CustomFields3;
import com.wicket.okrcomponent.base.service.dto.req.*;
//import com.wicket.okrcomponent.base.service.dto.res.*;

import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import java.lang.reflect.Field;
import java.util.*;
import java.util.stream.Collectors;
import java.util.ArrayList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author ：
 * @since 2022/1/19 15:39
 *
 *
 * @version 1.0
 */
@Service
public class MCustomFields3ServiceImpl
  extends ServiceImpl<CustomFields3Mapper, CustomFields3>
  implements MCustomFields3Service {

  @Autowired
  CustomFields3Mapper customFields3Mapper;
/**
   * M2执行分析自然日数据集（特殊方法）[5376]
   * gen by moon at 12/3/2022, 4:34:50 PM
   */
 @Trace(operationName = "M2执行分析自然日数据集（特殊方法）")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  List<CustomFields3>  implementAnalyzeNaturalDayData(ImplementAnalyzeNaturalDayDataReq reqDto) {
     
        try {
            QueryWrapper<CustomFields3> queryWrapper = new QueryWrapper<>();
            
            
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(CustomFields3.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(CustomFields3.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper,likeList,fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap,likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(CustomFields3.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            
            return ((List<CustomFields3>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1",e,false);
        }
  }

}

